package org.i_plus.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.i_plus.model.MemberBean;
import org.i_plus.model.services.MemberService;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class TodayBestServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
				WebApplicationContext context =
				WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
				MemberService service = (MemberService)context.getBean("MemberService");
				
				String temp = (String)req.getParameter("page");
				String thebest = (String)req.getParameter("thebest");
				int page = Integer.parseInt(temp);
				
				List<MemberBean> list = service.selectAll(page);
				req.setAttribute("members", list);
				req.setAttribute("page", page);
				
				req.getRequestDispatcher("/Manage/TodayBest.jsp").forward(req, resp);
				return;
	}
}
